package com.boxin.ims.modules.wechat.entity;

import java.util.Map;

/**
 * @author Jakemanse
 * @date 2013-6-20
 * @function <p> 事件推送消息 </p>
 *  <xml>
 *  	<ToUserName><![CDATA[toUser]]></ToUserName>
		<FromUserName><![CDATA[FromUser]]></FromUserName>
		<CreateTime>123456789</CreateTime>
		<MsgType><![CDATA[event]]></MsgType>
		<Event><![CDATA[EVENT]]></Event>
		<EventKey><![CDATA[EVENTKEY]]></EventKey>
	</xml>
 */
public class EventMessage extends Message {
	public final static String MSG_TYPE = "event";
	private Map<String,String> eventMap ;
	
	public final static String EVENT_TYPE_QUIT = "unsubscribe";
	public final static String EVENT_TYPE_JOIN = "subscribe";
	public final static String EVENT_VIEW = "VIEW";
	public final static String EVENT_CLICK = "CLICK";
	public final static String EVENT_TYPE_SCAN = "SCAN";
	
	public final static String EVENT_PIC_SYSPHTOTO = "pic_sysphoto";				//系统拍照发图
	public final static String EVENT_PIC_PHOTO_ALBUM = "pic_photo_or_album";		//系统拍照发图
	public final static String EVENT_PIC_WEIXIN = "pic_weixin";						//微信相册发图
	public final static String EVENT_LOCATION = "location_select";					//发送地理位置
	public final static String EVENT_SCANCODE_WAIT = "scancode_waitmsg";			//扫描带提示
	public final static String EVENT_SCANCODE_PUSH = "scancode_push";				//扫描带提示
	
	
	
	private String eventType;
	private String eventKey;
	
	
	/**
	 * 扫描事件相关参数
	 */
	private String ScanCodeInfo;		//扫描信息
	private String ScanType;			//扫描类型，一般是qrcode
	private String ScanResult;			//扫描结果，即二维码对应的字符串信息
	
	
	
	/**
	 * pic_photo_or_album  相关参数
	 */
	private String SendPicsInfo;		//发送的图片信息
	private String Count;				//发送的图片数量
	private String PicList;				//图片列表
	private String PicMd5Sum;			//图片的MD5值，开发者若需要，可用于验证接收到图片
	
	
	/**
	 * location_select  定位相关的参数
	 */
	private String SendLocationInfo;	//发送的位置信息
	private String Location_X;			//X坐标信息
	private String Location_Y;			//Y坐标信息
	private String Scale;				//精度，可理解为精度或者比例尺、越精细的话 scale越高
	private String Label;				//地理位置的字符串信息
	private String Poiname;				//朋友圈POI的名字，可能为空
	
	
	

	@Override
	public String getMsgType() {
		return MSG_TYPE;
	}
	
	
	
	
	/**
	 * @author Jakemanse
	 * @time 2014-9-20  上午10:28:01
	 * @function <p>  </p>
	 * @param eventMap
	 */
	public EventMessage(Map<String,String> eventMap){
		this.eventMap = eventMap;
		this.setContent(eventMap.get("xml.Content"));
		this.setMsgType(MSG_TYPE);
		this.setFromUserName(eventMap.get("xml.ToUserName"));
		this.setToUserName(eventMap.get("xml.FromUserName"));
		this.setCreateTime(eventMap.get("xml.CreateTime"));
		
		//
		this.setScanCodeInfo(eventMap.get("xml.ScanCodeInfo.ScanType"));
		this.setScanType(eventMap.get("xml.ScanCodeInfo.ScanType"));
		this.setScanResult(eventMap.get("xml.ScanCodeInfo.ScanResult"));
		
		
		//
		
	}
	
	

	@Override
	public String replyMessage() {
		StringBuffer sb  = new StringBuffer();
		sb.append("<xml>");
		sb.append("\t").append("<ToUserName><![CDATA["+this.getToUserName()+"]]></ToUserName>").append("\n");
		sb.append("\t").append("<FromUserName><![CDATA["+this.getFromUserName()+"]]></FromUserName>").append("\n");
		sb.append("\t").append("<CreateTime>"+System.currentTimeMillis()+"</CreateTime>").append("\n");
		sb.append("\t").append("<Content><![CDATA["+this.getContent()+"]]></Content>").append("\n");
		sb.append("\t").append("<MsgType><![CDATA["+TextMessage.MSG_TYPE+"]]></MsgType>").append("\n");
		sb.append("\t").append("<FuncFlag>0</FuncFlag>").append("\n");
		sb.append("</xml>");
		
		return sb.toString();
	}
	
	
	/**
	 * @author Jakemanse
	 * @time 2013-6-20  下午11:28:13
	 * @function <p> 回复图文消息 </p>
	 * <xml>
		 <ToUserName><![CDATA[toUser]]></ToUserName>
		 <FromUserName><![CDATA[fromUser]]></FromUserName>
		 <CreateTime>12345678</CreateTime>
		 <MsgType><![CDATA[news]]></MsgType>
		 <ArticleCount>2</ArticleCount>
		 <Articles>
		 <item>
		 <Title><![CDATA[title1]]></Title> 
		 <Description><![CDATA[description1]]></Description>
		 <PicUrl><![CDATA[picurl]]></PicUrl>
		 <Url><![CDATA[url]]></Url>
		 </item>
		 <item>
		 <Title><![CDATA[title]]></Title>
		 <Description><![CDATA[description]]></Description>
		 <PicUrl><![CDATA[picurl]]></PicUrl>
		 <Url><![CDATA[url]]></Url>
		 </item>
		 </Articles>
		 <FuncFlag>1</FuncFlag>
		 </xml> 
	 * @return
	 */
	public String replyImageMessage(ImageMessage imageMessage){
		
		return imageMessage.replyMessage();
		
	}
	
	
	
	/**
	 * @author Jakemanse
	 * @time 2013-6-20  下午11:24:25
	 * @function <p>  </p>
	 * @return
	 * <xml>
			 <ToUserName><![CDATA[toUser]]></ToUserName>
			 <FromUserName><![CDATA[fromUser]]></FromUserName>
			 <CreateTime>12345678</CreateTime>
			 <MsgType><![CDATA[music]]></MsgType>
			 <Music>
			 <Title><![CDATA[TITLE]]></Title>
			 <Description><![CDATA[DESCRIPTION]]></Description>
			 <MusicUrl><![CDATA[MUSIC_Url]]></MusicUrl>
			 <HQMusicUrl><![CDATA[HQ_MUSIC_Url]]></HQMusicUrl>
			 </Music>
			 <FuncFlag>0</FuncFlag>
 		</xml>
	 */
	public String replyMusicMessage(MusicMessage musicMessage){
		return musicMessage.replyMessage();
	}




	public Map<String, String> getEventMap() {
		return eventMap;
	}




	public void setEventMap(Map<String, String> eventMap) {
		this.eventMap = eventMap;
	}




	public String getEventType() {
		return eventType;
	}




	public void setEventType(String eventType) {
		this.eventType = eventType;
	}




	public String getEventKey() {
		return eventKey;
	}




	public void setEventKey(String eventKey) {
		this.eventKey = eventKey;
	}




	public String getScanCodeInfo() {
		return ScanCodeInfo;
	}




	public void setScanCodeInfo(String scanCodeInfo) {
		ScanCodeInfo = scanCodeInfo;
	}




	public String getScanType() {
		return ScanType;
	}




	public void setScanType(String scanType) {
		ScanType = scanType;
	}




	public String getScanResult() {
		return ScanResult;
	}




	public void setScanResult(String scanResult) {
		ScanResult = scanResult;
	}




	public String getSendPicsInfo() {
		return SendPicsInfo;
	}




	public void setSendPicsInfo(String sendPicsInfo) {
		SendPicsInfo = sendPicsInfo;
	}




	public String getCount() {
		return Count;
	}




	public void setCount(String count) {
		Count = count;
	}




	public String getPicList() {
		return PicList;
	}




	public void setPicList(String picList) {
		PicList = picList;
	}




	public String getPicMd5Sum() {
		return PicMd5Sum;
	}




	public void setPicMd5Sum(String picMd5Sum) {
		PicMd5Sum = picMd5Sum;
	}




	public String getSendLocationInfo() {
		return SendLocationInfo;
	}




	public void setSendLocationInfo(String sendLocationInfo) {
		SendLocationInfo = sendLocationInfo;
	}




	public String getLocation_X() {
		return Location_X;
	}




	public void setLocation_X(String location_X) {
		Location_X = location_X;
	}




	public String getLocation_Y() {
		return Location_Y;
	}




	public void setLocation_Y(String location_Y) {
		Location_Y = location_Y;
	}




	public String getScale() {
		return Scale;
	}




	public void setScale(String scale) {
		Scale = scale;
	}




	public String getLabel() {
		return Label;
	}




	public void setLabel(String label) {
		Label = label;
	}




	public String getPoiname() {
		return Poiname;
	}




	public void setPoiname(String poiname) {
		Poiname = poiname;
	}
	
	
	
	
	
	
	
	

}
